{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "https://langchain-ai.github.io/langgraph/how-tos/memory/delete-messages/#programmatically-deleting-messages\n",
    "\n",
    "https://github.com/langchain-ai/langchain-academy/blob/main/module-2/chatbot-summarization.ipynb\n",
    "\n",
    "message summarization and RemoveMessage"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "600e5b6dbc7cbddc"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "from langchain_openai import ChatOpenAI\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "model = ChatOpenAI(\n",
    "        # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key=\"sk-xxx\",\n",
    "        openai_api_key=os.getenv(\"DASHSCOPE_API_KEY\"),\n",
    "        openai_api_base=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n",
    "        model_name=\"qwen-max\",\n",
    "        verbose=True, temperature=0\n",
    "    )"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:01.715397Z",
     "start_time": "2024-12-09T08:30:59.625816Z"
    }
   },
   "id": "d43386df9c14564a",
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "from langgraph.graph import MessagesState\n",
    "class State(MessagesState):\n",
    "    summary: str"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:01.816585Z",
     "start_time": "2024-12-09T08:31:01.718509Z"
    }
   },
   "id": "e8faf3b52c0705a",
   "execution_count": 3
  },
  {
   "cell_type": "markdown",
   "source": [
    "incorporates a summary"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "1d9bf44221487292"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "from langchain_core.messages import SystemMessage, HumanMessage, RemoveMessage\n",
    "\n",
    "# Define the logic to call the model\n",
    "def call_model(state: State):\n",
    "    \n",
    "    # Get summary if it exists\n",
    "    summary = state.get(\"summary\", \"\")\n",
    "\n",
    "    # If there is summary, then we add it\n",
    "    if summary:\n",
    "        \n",
    "        # Add summary to system message\n",
    "        system_message = f\"Summary of conversation earlier: {summary}\"\n",
    "\n",
    "        # Append summary to any newer messages\n",
    "        messages = [SystemMessage(content=system_message)] + state[\"messages\"]\n",
    "    \n",
    "    else:\n",
    "        messages = state[\"messages\"]\n",
    "    \n",
    "    response = model.invoke(messages)\n",
    "    return {\"messages\": response}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:01.824909Z",
     "start_time": "2024-12-09T08:31:01.818811Z"
    }
   },
   "id": "f2cb845679489694",
   "execution_count": 4
  },
  {
   "cell_type": "markdown",
   "source": [
    "RemoveMessage"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "d1521f75f6f7a447"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "def summarize_conversation(state: State):\n",
    "    \n",
    "    # First, we get any existing summary\n",
    "    summary = state.get(\"summary\", \"\")\n",
    "\n",
    "    # Create our summarization prompt \n",
    "    if summary:\n",
    "        \n",
    "        # A summary already exists\n",
    "        summary_message = (\n",
    "            f\"This is summary of the conversation to date: {summary}\\n\\n\"\n",
    "            \"Extend the summary by taking into account the new messages above:\"\n",
    "        )\n",
    "        \n",
    "    else:\n",
    "        summary_message = \"Create a summary of the conversation above:\"\n",
    "\n",
    "    # Add prompt to our history\n",
    "    messages = state[\"messages\"] + [HumanMessage(content=summary_message)]\n",
    "    response = model.invoke(messages)\n",
    "    print(f\"summary: {response.content}\")\n",
    "    # Delete all but the 2 most recent messages\n",
    "    delete_messages = [RemoveMessage(id=m.id) for m in state[\"messages\"][:-2]]\n",
    "    return {\"summary\": response.content, \"messages\": delete_messages}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:01.843783Z",
     "start_time": "2024-12-09T08:31:01.833270Z"
    }
   },
   "id": "b8fcf1ed64e82ca2",
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "from langgraph.graph import END\n",
    "# Determine whether to end or summarize the conversation\n",
    "def should_continue(state: State):\n",
    "    \n",
    "    \"\"\"Return the next node to execute.\"\"\"\n",
    "    \n",
    "    messages = state[\"messages\"]\n",
    "    \n",
    "    # If there are more than six messages, then we summarize the conversation\n",
    "    if len(messages) > 6:\n",
    "        return \"summarize_conversation\"\n",
    "    \n",
    "    # Otherwise we can just end\n",
    "    return END"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:01.855246Z",
     "start_time": "2024-12-09T08:31:01.848233Z"
    }
   },
   "id": "c757e65daa43f0bf",
   "execution_count": 6
  },
  {
   "cell_type": "markdown",
   "source": [
    "graph"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "52ba0da1a112c8f9"
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAAp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1MlBX87u0pSx8LgI+vkglzt6799dqVy6hx/Kcg4qvzCaF9ztFP2dopaupMYpqc0oe2WFux5TpC7bhs7AH2LfMmNWiairaOS1UT6SukdLV07qdhjqHnXM6RutOJ0Nk7PQLpvGHWDIaqKputjttzqYmlkc1ZSRyvY094BcCQFqnY5tyt/r+f0Edws/wDZjiH/AMno/wD9DFaFUqvCbmZtW3L7nZaBjWsgt9FR0PY07GgAMZz07nADXcSV1HCcgIH/AJwr4NDzUdv6/wD4y66aqqKYp3Z5eHmi5LJsge7KscbHvtDc6fWj5g7bv/tDlD2O3VVroGwVl0qbxOHEmqqo4mPIPcNRMY3p/BbI4P4rLd8gZkEzC232/nZSuI12s5BY5zfraxpe3f8AecR3tK17VjU4Oz1V18uX1nuZU9t27URF+ZqIiICIiAiIgIiICIiAiIgIiICIiAiIgIiICIiDV+T8EoKqaSpx+sZanu2TRSxc9MTvfkgadHv7CW/U0KpycJMyjcQKa0yjfRzK+TqP5whb8Rezhfq21YVO7e/it82gPFRmX7FbPX3e6TxUZl+xWz193ulv9Fu/etpyjSfM5ZNAeKjMv2K2evu90niozL9itnr7vdLf6J+9bTlGk+ZyyaA8VGZfsVs9fd7pfW8JsycdfFLU0+YvuD9fz1CT/wAFv5E/etpyjT+zlk1FYeBs0srZchuTJIQetDbgWtf9j5XeUR9jQw/brotsUtLDQ00VPTQx09PCwRxxRNDWMaBoNAHQADpoLtReZtG1421TfFqvbQERFxoIiICIiD//2Q==",
      "text/plain": "<IPython.core.display.Image object>"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import Image, display\n",
    "from langgraph.checkpoint.memory import MemorySaver\n",
    "from langgraph.graph import StateGraph, START\n",
    "\n",
    "# Define a new graph\n",
    "workflow = StateGraph(State)\n",
    "workflow.add_node(\"conversation\", call_model)\n",
    "workflow.add_node(summarize_conversation)\n",
    "\n",
    "# Set the entrypoint as conversation\n",
    "workflow.add_edge(START, \"conversation\")\n",
    "workflow.add_conditional_edges(\"conversation\", should_continue)\n",
    "workflow.add_edge(\"summarize_conversation\", END)\n",
    "\n",
    "# Compile\n",
    "memory = MemorySaver()\n",
    "graph = workflow.compile(checkpointer=memory)\n",
    "display(Image(graph.get_graph().draw_mermaid_png()))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:02.823066Z",
     "start_time": "2024-12-09T08:31:01.859305Z"
    }
   },
   "id": "810558182b04026f",
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "\n",
      "Hi Lance! It's great to meet you. I see you're a big fan of the San Francisco 49ers. That's awesome! With such a talented roster, there's always a lot to be excited about.\n",
      "\n",
      "Do you have any favorite moments from past games or are you looking forward to any upcoming matches? Or is there anything specific about the 49ers that you're particularly excited about?\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "\n",
      "Your name is Lance! It's great to chat with you, Lance. Is there anything else you'd like to talk about, or do you have any other questions?\n",
      "summary: Sure! Here's an updated summary of our conversation:\n",
      "\n",
      "Lance introduced himself and mentioned that he is a fan of the San Francisco 49ers. He specifically highlighted his admiration for Nick Bosa, noting that Bosa is the highest-paid defensive player in the NFL. We discussed Bosa's exceptional skills and the impact he has on the 49ers' defense. Lance expressed his enthusiasm for the team and Bosa's contributions. Additionally, we touched on other notable players like Deebo Samuel and George Kittle. I asked if Lance had any favorite moments from past games or if he was looking forward to any upcoming matches. Lance confirmed his excitement about the 49ers but didn't specify any particular moments or players beyond Bosa.\n",
      "\n",
      "In the most recent exchanges, Lance reaffirmed his love for the 49ers, and I asked if there were any specific aspects of the team or the upcoming season that he was particularly excited about. Lance hasn't provided additional details about specific moments or players, but his enthusiasm for the 49ers remains clear.\n",
      "\n",
      "Is there anything else you'd like to add, Lance, or any other questions you have?\n",
      "{'messages': [HumanMessage(content='i like the 49ers!', additional_kwargs={}, response_metadata={}, id='6c4c0c69-2569-43fc-a55c-08a8503a8fa9'), AIMessage(content=\"That's fantastic, Lance! It's always exciting to chat with a fellow 49ers fan. The team has a lot of potential and some incredible players. \\n\\nDo you have any favorite moments from past games, or are you looking forward to any upcoming matches? Maybe there's a particular player you're excited to see perform this season?\", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 69, 'prompt_tokens': 450, 'total_tokens': 519, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'qwen-max', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-2e3b2994-2960-4419-9488-597499d0424d-0', usage_metadata={'input_tokens': 450, 'output_tokens': 69, 'total_tokens': 519, 'input_token_details': {}, 'output_token_details': {}})], 'summary': \"Sure! Here's an updated summary of our conversation:\\n\\nLance introduced himself and mentioned that he is a fan of the San Francisco 49ers. He specifically highlighted his admiration for Nick Bosa, noting that Bosa is the highest-paid defensive player in the NFL. We discussed Bosa's exceptional skills and the impact he has on the 49ers' defense. Lance expressed his enthusiasm for the team and Bosa's contributions. Additionally, we touched on other notable players like Deebo Samuel and George Kittle. I asked if Lance had any favorite moments from past games or if he was looking forward to any upcoming matches. Lance confirmed his excitement about the 49ers but didn't specify any particular moments or players beyond Bosa.\\n\\nIn the most recent exchanges, Lance reaffirmed his love for the 49ers, and I asked if there were any specific aspects of the team or the upcoming season that he was particularly excited about. Lance hasn't provided additional details about specific moments or players, but his enthusiasm for the 49ers remains clear.\\n\\nIs there anything else you'd like to add, Lance, or any other questions you have?\"}\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "\n",
      "That's fantastic, Lance! It's always exciting to chat with a fellow 49ers fan. The team has a lot of potential and some incredible players. \n",
      "\n",
      "Do you have any favorite moments from past games, or are you looking forward to any upcoming matches? Maybe there's a particular player you're excited to see perform this season?\n"
     ]
    }
   ],
   "source": [
    "# Create a thread\n",
    "config = {\"configurable\": {\"thread_id\": \"1\"}}\n",
    "\n",
    "# Start conversation\n",
    "input_message = HumanMessage(content=\"hi! I'm Lance\")\n",
    "output = graph.invoke({\"messages\": [input_message]}, config) \n",
    "for m in output['messages'][-1:]:\n",
    "    m.pretty_print()\n",
    "\n",
    "input_message = HumanMessage(content=\"what's my name?\")\n",
    "output = graph.invoke({\"messages\": [input_message]}, config) \n",
    "for m in output['messages'][-1:]:\n",
    "    m.pretty_print()\n",
    "\n",
    "input_message = HumanMessage(content=\"i like the 49ers!\")\n",
    "output = graph.invoke({\"messages\": [input_message]}, config) \n",
    "print(output)\n",
    "for m in output['messages'][-1:]:\n",
    "    m.pretty_print()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:45:23.307753Z",
     "start_time": "2024-12-09T08:34:40.287895Z"
    }
   },
   "id": "fd2a37c8a00bde22",
   "execution_count": 12
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "\n",
      "Yes, you're absolutely right! Nick Bosa is indeed one of the highest-paid defensive players in the NFL. In March 2023, he signed a five-year, $130 million contract extension with the San Francisco 49ers, making him one of the top-earning defensive players in the league. His performance on the field has been nothing short of spectacular, and he's a key reason why the 49ers' defense is so formidable.\n",
      "\n",
      "Bosa's ability to disrupt offenses and his relentless pass-rushing skills make him a standout player. He's not just a fan favorite but also a crucial part of the team's success.\n",
      "\n",
      "Are there any other players or aspects of the team that you're particularly excited about this season?\n"
     ]
    }
   ],
   "source": [
    "input_message = HumanMessage(content=\"i like Nick Bosa, isn't he the highest paid defensive player?\")\n",
    "output = graph.invoke({\"messages\": [input_message]}, config)\n",
    "print(len(output['messages']))\n",
    "for m in output['messages'][-1:]:\n",
    "    m.pretty_print()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:47:56.883726Z",
     "start_time": "2024-12-09T08:45:39.328508Z"
    }
   },
   "id": "8030801d0a1c6e60",
   "execution_count": 13
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "\"Sure! Here's a summary of our conversation:\\n\\nLance introduced himself and mentioned that he is a fan of the San Francisco 49ers. He specifically highlighted his admiration for Nick Bosa, noting that Bosa is the highest-paid defensive player in the NFL. We discussed Bosa's exceptional skills and the impact he has on the 49ers' defense. Lance didn't mention any other specific players or moments, but the conversation centered around his enthusiasm for the team and Bosa's contributions.\""
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.get_state(config).values.get(\"summary\",\"\")\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-12-09T08:31:27.479810Z",
     "start_time": "2024-12-09T08:31:27.458953Z"
    }
   },
   "id": "7d40a94832907206",
   "execution_count": 10
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
